#include <stdlib.h>
#include <structures_donnees.h>

File creer_file(void)
{
	return (creer_liste()) ;
}

int file_vide(File f)
{
	return (est_vide(f)) ;
}

void visualiser_file(File f)
{
	if (est_vide(f))
	{;}
	else
	{
		File browse ;
		browse = f ;
		affiche(&(browse->element)) ;
		while (browse->next != f)
		{
			browse = browse->next ;
			affiche(&(browse->element)) ;		
		}
	}
}

File enfiler(type element, File f)
{
	if (file_vide(f))
	{
		f = calloc (1, sizeof(*f)) ;
		f->element = element ;
		f->next = f ;
		return (f) ;
	}
	else
	{
		File queue ;
		File browse ;
		queue = calloc(1, sizeof(*queue)) ;
		queue->element = element ;
		queue->next = f ;
		browse = f ;
		while (browse->next != f)
		{
			browse = browse->next ;
		}
		browse->next = queue ;
		return queue ;
	}
}

type defiler(File *f)
{
	type element ;
	element = NULL ;
	File browse ;
	browse = *f ;
	if (est_vide(*f))
	{
		return element ;
	}
	else if (browse->next == (*f))
	{
		element = browse->element ;
		*f = creer_file() ;
		
		return (element) ;
	}
	else
	{
		while (browse->next->next != *f)
		{
			browse = browse->next ;
		}
		element = browse->next->element ;
		browse->next = *f ;
		return (element) ;
	}
}
